Overview
Homomorphic operations preserve the algebraic structure:All operations are exact (no approximation errors) and work over the 127-bit prime field F_p.
Addition
Addition is extremely fast: simply concatenate the layer graphs and edge lists.include/pvac/ops/arithmetic.hpp:165-188:
Why addition is fast
Addition doesn’t create new layers or multiply edges. It just:- Merges layer lists (adjusting PROD layer parent indices)
- Concatenates edge lists (adjusting layer IDs)
- Adds constant terms
- Time: 0.012 ms (12 microseconds)
- Ciphertext growth: None (just concatenation)
- Noise growth: Linear
Example
Subtraction
Subtraction is addition with negation:include/pvac/ops/arithmetic.hpp:152-163.
Performance: Same as addition (~0.012 ms).
Multiplication
Multiplication creates new PROD layers representing cross-products of parent layers.S controls the number of edges per product layer (default: 8).
From include/pvac/ops/arithmetic.hpp:194-225:
Multiplication algorithm
GivenA = a0 + g_A and B = b0 + g_B where a0, b0 are constants and g_A, g_B are graph parts:
- Product layers: For each pair
(la, lb)wherela ∈ layers(A)andlb ∈ layers(B), create a PROD layer:
include/pvac/ops/arithmetic.hpp:90-94.
- Repack edges: For each PROD layer, create
Snew edges that encode the product value:
s-1 random edges, then solve for the last edge’s weight to match the target sum.
From include/pvac/ops/arithmetic.hpp:55-88.
-
Add cross terms: Scale B’s edges by
a0and A’s edges byb0. -
Compute constant:
c0 = a0 * b0.
Why multiplication is more expensive
- Layer growth:
|L_C| = |L_A| + |L_B| + |L_A| × |L_B| - Edge growth: New edges for each product layer
- Compaction: May trigger edge merging if budget exceeded
- Time: 2.47 ms
- vs BFV: 2.9× faster (shallow), 7.4× faster (leveled)
- vs CKKS: 14.3× faster
From
benchmarks/README.md:42-50, PVAC-HFHE multiplication is significantly faster than RLWE schemes for scalar operations.Example
Squaring
Squaring is optimized compared to generic multiplication:include/pvac/ops/arithmetic.hpp:227-255:
LA*(LA+1)/2 PROD layers instead of LA², exploiting symmetry.
Constant operations
Operations with public constants are much faster:Addition with constant
include/pvac/ops/arithmetic.hpp:269-275.
Free operation: Only updates constant term, no layer/edge changes.
Multiplication by constant
include/pvac/ops/arithmetic.hpp:261-263.
Fast operation: Scales all edge weights, no new layers.
Division by constant
include/pvac/ops/arithmetic.hpp:257-259.
Requires field inversion of the constant.
Depth and noise growth
Multiplicative depth
The depth of a ciphertext is the longest path of multiplications from fresh encryptions:- Fresh encryption: depth 0
- Addition/subtraction:
max(depth(A), depth(B)) - Multiplication:
depth(A) + depth(B) + 1
Noise budget
Noise grows with depth:- Base: 120 bits
- Growth: 16 bits per depth
- At depth 5: 120 + 16*5 = 200 bits
Performance comparison
Frombenchmarks/README.md:42-72:
Scalar multiplication
Scalar addition
PVAC-HFHE excels at shallow circuits (depth 1-2) with scalar operations, significantly outperforming RLWE schemes.
Ciphertext management
Edge budget
When ciphertext edges exceed the budget (default: 1,200,000), automatic compaction triggers:Compaction
Merges edges pointing to the same (layer, index, sign):include/pvac/ops/encrypt.hpp:658-660.
Also removes unused layers:
Code examples
Polynomial evaluation
Dot product
Next steps
Security
Understand the LPN-based security model
API reference
Explore the complete API